﻿using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;

namespace QWManage.Model
{
    public class ExtagsConfigInfo
    {
        public List<string> TagIds { get; set; } = new List<string>();
    }

    public class ExtagsConfigMgr
    {

        public static ExtagsConfigInfo Get()
        {
            ExtagsConfigInfo obj = null;
            try
            {
                string fn = Path.Combine(Application.StartupPath, "myextagscfg.dll");
                if (File.Exists(fn))
                {
                    string json = File.ReadAllText(fn);
                    obj = JsonConvert.DeserializeObject<ExtagsConfigInfo>(json);
                    return obj;
                }
            }
            catch { }
            if (obj == null) { obj = new ExtagsConfigInfo(); }
            return obj;
        }

        public static void Set(ExtagsConfigInfo info)
        {
            try
            {
                string fn = Path.Combine(Application.StartupPath, "myextagscfg.dll");
                {
                    string json = JsonConvert.SerializeObject(info);
                    File.WriteAllText(fn, json);
                }
            }
            catch { }
        }
    }
}
